package com.smarthome.core.advicemanager.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.smarthome.base.service.ShAccountMessageService;
import com.smarthome.common.tools.EnumUtil;
import com.smarthome.core.advicemanager.SystemMessageService;
import com.smarthome.domain.bean.ShAccountMessage;
import com.smarthome.domain.enums.AccountMessageReceiveStatus;
import com.smarthome.domain.enums.AccountMessageSendStatus;
import com.smarthome.domain.vo.boss.Combobox;
import com.smarthome.domain.vo.boss.DataGrid;
import com.smarthome.domain.vo.boss.PageHelper;
/**
 * 
* @ClassName: SystemMessageServiceImpl
* @Description: TODO(系统消息服务接口实现类)
* @author cyj
* @date 2015年9月28日 下午11:39:43
*
 */
@Service("systemMessageService")
public class SystemMessageServiceImpl implements SystemMessageService {

	@Resource
	private ShAccountMessageService accountMessageService;
	
	@Override
	public ShAccountMessage queryShAccountMessageById(Long id) {
		return accountMessageService.selectEntryById(id);
	}

	@Override
	public DataGrid qeuryDataGrid(ShAccountMessage accountMessage,
			PageHelper page) {
		return accountMessageService.quetyDataGrid(accountMessage, page);
	}

	@Override
	public int saveOrUpdate(ShAccountMessage accountMessage) {
		return accountMessageService.saveOrUpdate(accountMessage);
	}

	@Override
	public int delete(Long id) {
		return accountMessageService.deleteByIds(id);
	}

	@Override
	public List<Combobox> sendStatus() {
		List<Combobox> result = new ArrayList<>();
		List<AccountMessageSendStatus> statusEnum = EnumUtil.getEnumList(AccountMessageSendStatus.class);
		for(AccountMessageSendStatus status:statusEnum) {
			result.add(new Combobox(String.valueOf(status.getCode()),status.getName()));
		}
		return result;
	}

	@Override
	public List<Combobox> recieveStatus() {
		List<Combobox> result = new ArrayList<>();
		List<AccountMessageReceiveStatus> statusEnum = EnumUtil.getEnumList(AccountMessageReceiveStatus.class);
		for(AccountMessageReceiveStatus status:statusEnum) {
			result.add(new Combobox(String.valueOf(status.getCode()),status.getName()));
		}
		return result;
	}

	@Override
	public List<ShAccountMessage> getAccountMessages(
			ShAccountMessage queryAccountMessage) {
		return accountMessageService.queryAccountMessageList(queryAccountMessage);
	}

	@Override
	public int add(ShAccountMessage... accountMessages) {
		return accountMessageService.insert(accountMessages);
	}

	@Override
	public int count(ShAccountMessage accountMessages) {
		return accountMessageService.count(accountMessages);
	}

	@Override
	public int batchUpdate(ShAccountMessage accountMessage) {
		return accountMessageService.batchUpdate(accountMessage);
	}

	


}
